package com.zhj.product.controller;

import com.zhj.product.entity.dto.ItemsCommentsPageDTO;
import com.zhj.product.entity.dto.ItemsCommentsLevelDTO;
import com.zhj.product.entity.dto.ItemsDTO;
import com.zhj.product.entity.req.ItemsCommentsPageReq;
import com.zhj.product.service.ItemsCommentsService;
import com.zhj.product.service.ItemsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/items")
@Api(tags = "商品详情页")
public class ItemsController {

    @Resource
    private ItemsService itemsService;

    @Resource
    private ItemsCommentsService itemsCommentsService;

    /**
     * 查询首页的轮播图
     * @return
     */
    @GetMapping("/info/{itemId}")
    @ApiOperation(("查询商品详情"))
    public ItemsDTO selectItemsById(@PathVariable("itemId") String itemId) {
        return itemsService.selectItemById(itemId);
    }

    /**
     * 查询商品评论
     * @return
     */
    @GetMapping("/comments")
    @ApiOperation(("查询"))
    public ItemsCommentsPageDTO selectItemsCommentsPage(ItemsCommentsPageReq itemsCommentsPageReq) {
        return itemsCommentsService.selectItemsCommentsPage(itemsCommentsPageReq);
    }

    /**
     * 查询商品评论
     * @return
     */
    @GetMapping("/commentLevel")
    @ApiOperation(("查询评价数量"))
    public ItemsCommentsLevelDTO selectItemsCommentsLevel(@RequestParam("itemId") String itemId) {
        return itemsCommentsService.selectItemsCommentsLevel(itemId);
    }



}
